//length section

		
function calcLength(){
	
	newt1 = parseFloat(document.frm1.t1.value);
	var rslt;
	 // convert to mm
	if(document.frm1.list1.selectedIndex == 1) {newt1 *= 10;}
	if(document.frm1.list1.selectedIndex == 2) {newt1 *= 304.8;}		
	if(document.frm1.list1.selectedIndex == 3) {newt1 *= 25.4;}
	if(document.frm1.list1.selectedIndex == 4) {newt1 *= 1000000;}
	if(document.frm1.list1.selectedIndex == 5) {newt1 *= 1000;}
	if(document.frm1.list1.selectedIndex == 6) {newt1 *= 1609300;}
	if(document.frm1.list1.selectedIndex == 7) {newt1 *= 1;}
	if(document.frm1.list1.selectedIndex == 8) {newt1 *= 914.4;}
	
		
	 // convert to user's choice
	if(document.frm1.list2.selectedIndex == 1) {newt1 /= 10;}
	if(document.frm1.list2.selectedIndex == 2) {newt1 /= 304.8;}
	if(document.frm1.list2.selectedIndex == 3) {newt1 /= 25.4;}
	if(document.frm1.list2.selectedIndex == 4) {newt1 /= 1000000;}
	if(document.frm1.list2.selectedIndex == 5) {newt1 /= 1000;}
	if(document.frm1.list2.selectedIndex == 6) {newt1 /= 1609300;}
	if(document.frm1.list2.selectedIndex == 7) {newt1 /= 1;}
	if(document.frm1.list2.selectedIndex == 8) {newt1 /= 914.4;}

	//fnewt1 = reducedec(newt1);
	document.frm1.result.value = newt1;
}	
function reducedec(newt1){//reduce dec numbers to 4
	var fnewt1;
	newt1 = newt1*10000;
	intnewt1 = Math.round(newt1);
	var stringnewt1= intnewt1.toString();
	var len = stringnewt1.length;
	var fnewt1 = stringnewt1.substring(0,len -4) +"." + stringnewt1.substring(len -4,len);
	
	if (fnewt1.indexOf(".") == 0){
		fnewt1 = "0" + fnewt1;
	}
				
	len = fnewt1.length;
	//find the dot
 	var decdot = fnewt1.indexOf(".");
 	//extract dot + numbers after it
 	var extdecim = fnewt1.substring(decdot, len);
 	// get the length of the dot + dec positions. 
 	//   add 0 till number of decimals = 4  
 		
 	while(extdecim.length < 5){
 		extdecim = extdecim + "0"; 
 	}
 		
	fnewt1 = fnewt1.slice(0, decdot);
	fnewt1 = fnewt1 + extdecim;
		
	return fnewt1;
	
}


function checkt1(){
	
	if(isNaN(document.frm1.t1.value)){
			document.frm1.t1.value="";
			document.frm1.t1.focus();  
	}
}